<script setup>
import { ref } from 'vue';
import Axios from 'axios';
//  index.html  <script type="module" src="./node_modules//tiff.js/tiff.min.js"></script>
// 到底要怎么引入  tiff.js 这源文件里都没有 export
// 到底要怎么引入
// 到底要怎么引入
// 到底要怎么引入
// 到底要怎么引入
// 到底要怎么引入

import '../node_modules/tiff.js/tiff.min.js'; // Download tiff.min.js and load the script by yourself:

// import '../node_modules/browser-tiff.js/tiff.min.js';
// import Tiff from 'tiff.js';
// import * as Tiff from 'tiff.js';
// import * as Tiff from 'browser-tiff.js';

let imgURL = ref()
Axios({
  url: 'http://fsse-status.fsse.vip/scoring/20230606/b2be8e54387e44908d3b26b86775eaec.22.tif',
  method: 'get',
  responseType: 'arraybuffer',
  headers: {
    'Access-Control-Allow-Origin': '*',
    'Content-Type': 'application/octet-stream',
  },
}).then((res) => {
  const buffer = res.data;
  console.log('buffer', buffer);
  const instance = new Tiff({ buffer });
  const canvas = instance.toCanvas();
  imgURL.value = canvas.toDataURL();
  console.log('imgURL', imgURL);
});
</script>

<template>
  <img :src="imgURL" alt="tif文件" />
</template>
